#include "src/dul_linked_list/dul_linked_list.cpp"

void TestLinkList() {

    DuLinkList list = InitLinkedList();

    //ListInsert(list, 1, 20);
    ListInsert(list, 1, 10);
    ListInsert(list, 2, 20);
    ListInsert(list, 3, 30);
    ListInsert(list, 4, 40);
    ListInsert(list, 5, 50);
    ListInsert(list, 6, 60);
    printf("After inserting :\n");
    Print(list);

    int value = GetElemType(list, 2);
    if (value != -1) {
        printf("\nThe value at postion 2 is: %d\n", value);
    }

    //无效位置
    printf("\nThe value at postion 20 is:");
    GetElemType(list, 20);
   

    int position = GetElem(list, 40);
    if (position != -1) {
        printf("\nThe position with 40 is: %d\n", position);
    }
    else {
        printf("\nThe value  is not in the list: %d\n",position);
    }

    printf("\nInsert value 300 at postion 3:");
    ListInsert(list, 3, 300);
    printf("\nAfter inserting :\n");
    Print(list);
    int length = ListLength(list);
    printf("\nLength of the list : %d\n", length);

    ListDelete(list, 3);
    printf("\nAfter deleting the 3nd element :\n");
    Print(list);
    length = ListLength(list);
    printf("\nLength of the list : %d\n", length);


    ListClear(list);
    printf("\nAfter clearing the list element :\n");
    Print(list);
    length = ListLength(list);
    printf("\nLength of the list : %d\n", length);

    free(list);
}


int main()
{
    TestLinkList();

    return 0;
}

